package interfaces.menu.joinGame.gamesTable;

import map.infos.MapInfos;

import org.fenggui.util.Color;

import fileHandling.MapLoader;
import fileHandling.language.LanguageLoader;
import fileHandling.language.interfaces.JoinGameText;
import fileHandling.language.options.OptionValues;
import interfaces.tables.TableEntry;

public class GamesTableEntry extends TableEntry {
	
	protected GamesTableWidget widget;
	
	public GamesTableEntry(int width, int height, int x, GamesTable table, GamesTableWidget widget) {
		super(width, height, x, table);
		this.widget = widget;
		
		setValueOf(JoinGameText.Server_Name, widget.getServerName());
		MapInfos infos = MapLoader.getMapInfos(widget.getCurrentMap());
		setValueOf(JoinGameText.Current_Map, infos.getMapName());
		String mode = LanguageLoader.get(OptionValues.valueOf(widget.getGameMode().toString()));
		setValueOf(JoinGameText.Game_Mode, mode);
		setValueOf(JoinGameText.Players, widget.getPlayers().size() + "/" + widget.getMaxPlayers());
		setValueOf(JoinGameText.Ping, widget.getPing() + "");
	}
	
	public GamesTableWidget getGamesTableWidget() { return widget; }
	
	@Override
	public Color getNormalBGColor() { return Color.TRANSPARENT; }
	
	@Override
	public Color getSelectedBGColor() {return Color.LIGHT_BLUE; }
}